home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 040 (1987-11-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 040 (1987-11-15)(Ossowski, Stefan)(DE)(PD).adf / A68k / a68kglb.h < prev    next >
C/C++ Source or Header  |  1989-01-18  |  7KB  |  171 lines

  1. /*------------------------------------------------------------------*/
  2. /*                                    */
  3. /*              MC68000 Cross Assembler                */
  4. /*                                    */
  5. /*           Copyright (c) 1985 by Brian R. Anderson            */
  6. /*                                    */
  7. /*        Global variables - September 3,    1987            */
  8. /*                                    */
  9. /*   This program may be copied    for personal, non-commercial use    */
  10. /*   only, provided that the above copyright notice is included        */
  11. /*   on    all copies of the source code.    Copying    for any    other use   */
  12. /*   without the consent of the    author is prohibited.            */
  13. /*                                    */
  14. /*------------------------------------------------------------------*/
  15. /*                                    */
  16. /*        Originally published (in Modula-2) in            */
  17. /*        Dr.    Dobb's Journal, April, May, and June 1986.          */
  18. /*                                    */
  19. /*    AmigaDOS conversion copyright (c) 1987 by Charlie Gibbs.    */
  20. /*                                    */
  21. /*------------------------------------------------------------------*/
  22.  
  23. #ifdef PRIMARY
  24. #define    GLOBAL
  25. #else
  26. #define    GLOBAL extern
  27. #endif
  28.  
  29. GLOBAL char SourceFN[MAXFN];        /* Source file name */
  30. GLOBAL char HeaderFN[MAXFN];        /* Header file name */
  31. GLOBAL FILE *InFile, *List, *Srec;    /* File    pointers */
  32. GLOBAL char InclList[MAXLINE];        /* List    of directories to search */
  33. GLOBAL char IdntName[MAXLINE];        /* Program unit    name */
  34. GLOBAL int LnCnt;    /* Number of lines on current page */
  35. GLOBAL int LnMax;    /* Maximum number of lines per page */
  36. GLOBAL int PgCnt;    /* Page    number */
  37. GLOBAL int XrefList;    /* Produce a cross-reference listing */
  38. GLOBAL int ListOff;    /* Suppress the    listing    file */
  39. GLOBAL int DumpSym;    /* Dump    the symbol table */
  40.  
  41. GLOBAL char TTLstring[MAXLINE];        /* Title string    */
  42.  
  43. GLOBAL int  LabLine;            /* Last    labeled    line number */
  44. GLOBAL int  LineCount;            /* Source line counter */
  45. GLOBAL char Line[MAXLINE];        /* Current source line */
  46. GLOBAL char Label[MAXLINE];        /* Instruction label */
  47. GLOBAL char OpCode[MAXLINE];        /* Instruction mnemonic    */
  48. GLOBAL char SrcOp[MAXLINE];        /* First (source) operand */
  49. GLOBAL char DestOp[MAXLINE];        /* Second (destination)    operand    */
  50. GLOBAL int  OpLoc, SrcLoc, DestLoc;    /* Operands start here */
  51. GLOBAL int  Dir, PrevDir;        /* Assembler directive */
  52. GLOBAL int  NumSyms;            /* Number of symbols */
  53. GLOBAL long ObjOp, ObjSrc, ObjDest;    /* OpCode, Source, Dest. */
  54. GLOBAL char ObjString[MAXLINE];        /* String data */
  55. GLOBAL int  nO,    nS, nD,    nX;        /* Length of above components */
  56. GLOBAL int  PrntAddr;            /* Print AddrCnt on listing */
  57. GLOBAL int  SuppList;            /* Suppress listing file */
  58. GLOBAL long Hunk2;            /* Hunk    number (from GetValue) */
  59. GLOBAL int  DefLine2;            /* Definition line number */
  60. GLOBAL int  GotEqur;            /* We have register equates */
  61.  
  62. GLOBAL int  Pass2;    /* Pass    2 flag */
  63. GLOBAL long AddrCnt;    /* Location counter */
  64. GLOBAL long AddrAdv;    /* Bump    AddrCnt    by this    much */
  65. GLOBAL long EndAddr;    /* END statement transfer address */
  66. GLOBAL long SectStart;    /* Current section (or portion)    starts here */
  67. GLOBAL int  SectLine;    /* Line    number where section started */
  68. GLOBAL long HunkType;    /* Current hunk    type */
  69. GLOBAL long HunkFlags;    /* Hunk    flags (MEMF_FAST or MEMF_CHIP) */
  70. GLOBAL long CurrHunk;    /* Current hunk    number */
  71. GLOBAL long NextHunk;    /* Next    available hunk number */
  72. GLOBAL long LenPos;    /* Seek    position of current hunk length    */
  73.  
  74. GLOBAL int  SFormat;    /* Generate S-record format */
  75. GLOBAL long StartAddr;    /* Address that    record starts on */
  76. GLOBAL long TempAddr;    /* Address of where we are now */
  77.  
  78. struct SymTab {                /* Symbol table    */
  79.     char *Nam;    /* Pointer to symbol (on heap) */
  80.     long Val;    /* Value */
  81.     long Hunk;    /* Hunk    no. (~(external    symbol heap offset) if < 0) */
  82.     int     Defn;    /* Line    number where defined */
  83.     int     Flags;    /* Flags bits:    0 - XREF
  84.                 1 - XDEF
  85.                 2 - SET
  86.                 3 - MACRO (symbol is preceded by blank)
  87.                 4 - SECTION (name preceded by 2    blanks)
  88.                 5 - register name (EQUR)
  89.                 6 - register list (REG)    */
  90.     struct Ref *Ref1;    /* Pointer to first reference entry */
  91. };
  92. GLOBAL struct SymTab *SymStart;    /* The symbol table starts here    */
  93. GLOBAL struct SymTab *Sym;    /* ReadSymTab sets this    up */
  94. GLOBAL struct SymTab *Sect;    /* Current section's entry */
  95.  
  96. struct Ref {        /* Reference entry */
  97.     struct Ref *NextRef;    /* Pointer to next reference entry */
  98.     int    RefNum[MAXREF];        /* Reference line numbers */
  99. };
  100. GLOBAL struct Ref *RefStart;    /* Reference entries start here    */
  101.  
  102. struct RelTab {        /* Relocation table - goes on the heap */
  103.     long Offset;    /* Offset to relocatable value */
  104.     long Hunk;        /* Hunk    type to    relocate relative to */
  105.     int    Size;        /* Size    of relocatable value */
  106. };
  107. GLOBAL struct RelTab *RelStart;    /* Relocation data starts here */
  108.  
  109. struct TermStack {        /* Parser's term stack */
  110.     long value;        /* Value */
  111.     int     hunk;        /* Hunk    number */
  112.     int     oploc;        /* Location in source statement    */
  113.     int     defline;    /* Line    number where defined */
  114. };
  115. GLOBAL struct TermStack    *Term;    /* Term    stack pointer */
  116.  
  117. struct OpStack {        /* Parser's operator stack */
  118.     char chr;        /* Operator character */
  119.     int     prec;        /* Precedence */
  120. };
  121. GLOBAL struct OpStack *Ops;    /* Operator stack pointer */
  122.  
  123. GLOBAL char *Heap;    /* Primary heap    - allocated by "malloc" */
  124. GLOBAL char *HeapLim;    /* Next    unused space on    the heap */
  125. GLOBAL char *HighHeap;    /* High-water mark on the heap */
  126. GLOBAL char *LowHeap;    /* Low limit from top of heap */
  127.  
  128. GLOBAL int  InFNum;        /* Current input nesting level */
  129. struct InFCtl {
  130.     long Pos;            /* Current position in input */
  131.     char *UPtr;            /* Current position in user macro or 0 */
  132.     char *NPtr;            /* File    name stack pointer */
  133.     int     Line;            /* Current line    number in this file */
  134.     int     NArg;            /* Number of macro arguments or    -1 */
  135.     int     MCnt;            /* Macro expansion number (for \@) */
  136. };
  137. GLOBAL struct InFCtl *InF;    /* Macro/include file stack pointer */
  138. GLOBAL struct InFCtl *LowInF;    /* "Low-water mark" for InF */
  139. GLOBAL char *Heap2;        /* Secondary heap */
  140. GLOBAL char *NextFNS;        /* Next    input file path/name */
  141. GLOBAL char *High2;        /* Secondary high-water    mark */
  142. GLOBAL char *Low2;        /* Low limit from top of heap */
  143.  
  144. GLOBAL int  OuterMac;        /* Level number    of outermost macro */
  145. GLOBAL int  MacCount;        /* Number of macros expanded */
  146. GLOBAL int  SkipNest;        /* Skipped IF/ENDC nesting count */
  147.  
  148. struct OpConfig    {        /* Operand configuration */
  149.     long Value;    /* Value */
  150.     long Hunk;    /* Hunk    number */
  151.     int     Defn;    /* Line    number where defined */
  152.     int     Mode;    /* Addressing mode */
  153.     int     Loc;    /* Location of operand on Line */
  154.     int     Rn;    /* Register number */
  155.     int     Xn;    /* Index register number */
  156.     int     Xsize;    /* Size    of index */
  157.     int     X;    /* Is index Data or Address reg? */
  158. };
  159. GLOBAL struct OpConfig Src, Dest;   /* Source and destination operands */
  160.  
  161. GLOBAL int Size;    /* size    for OpCode */
  162. GLOBAL int InstSize;    /* Size    of instruction,    including operands */
  163. GLOBAL int AdrModeA;    /* Addressing modes for    this instruction */
  164. GLOBAL int AdrModeB;    /*         ditto             */
  165. GLOBAL int Op;        /* Raw bit pattern for OpCode */
  166.  
  167. GLOBAL int ErrorCount;
  168.  
  169. /* Error message tables    */
  170. GLOBAL int errlim, errcode[ERRMAX], errpos[ERRMAX];
  171.